const app = new Vue({
    el: '#login',
    data: {

        baseUrl: "http://shot.com/",
        user: {
            username: '',
            password: '',
        },
        token: ''
    },
    methods: {
        submit() {
            let that = this
            console.log(that.user.username);

            axios
                .post(that.baseUrl + 'students/userLogin/', that.user)
                .then(res => {
                    //执行成功
                    if (res.data.code === 0) {
                        //获取所有学生的信息
                        that.token = res.data.token;
                        sessionStorage.setItem("userName", res.data.username);
                        sessionStorage.setItem("token", res.data.token);
                        window.location.href="../../index.html";
                        //提示
                        that.$message({
                            message: res.data.msg,
                            type: 'success'
                        });
                    } else {
                        that.$message.error(res.data.msg);
                    }
                })
                .catch(err => {
                    //执行失败
                    console.log(err);
                    that.$message.error("登录出现异常");
                })
        },
    },
})